package com.twu.biblioteca.ui.menus.books;

import com.twu.biblioteca.items.Book;
import com.twu.biblioteca.library.Library;
import com.twu.biblioteca.ui.menus.AbstractMenu;

/**
 * @author Alvi Jonathan Sait
 */
public class CheckoutBookMenu extends ListBooksMenu {

    public CheckoutBookMenu(Library library) {
        super(library);
    }

    @Override
    public AbstractMenu handleInput(String input) {
        Book book = getLibrary().getBooks().get(input);
        if (book != null && book.isAvailable()) {
            book.acceptCheckouter(getUser());
            return new SuccessfulBookCheckoutMenu(getLibrary());
        }
        return new UnsuccessfulBookCheckoutMenu(getLibrary());
    }


    @Override
    public String getUserPrompt() {
        return "Enter the ISBN of the book you would like to checkout:";
    }

    @Override
    protected void addMenuItems() {
        // No Menu Items needed in here since user must input the ISBN.
    }
}
